/**
 * 
 * @param {type} domain
 * @returns {undefined}
 * 
 */
function changePass(domain) {
    $.ajax({
        // The link we are accessing.
        url: domain + "ajax.php",
        // The type of request.
        type: "post",
        data: "act=change_pass&curpass=" + $('#cur-password').val() + "&pass=" + $('#password').val() + "&id=" + $('#id').val(),
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
            // Load the content in to the page.
            $("#error").html("<label>Page Not Found!!</label>");
            $("#error").css({display: "block"});
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData != "") {
                $("#error").html(strData);
                $("#error").css({display: "block"});
            } else {
//                                    window.location.href = <?php echo DOMAIN ?>;
            }
        }
    });
}

function changeUserInfo(domain) {
    $.ajax({
        // The link we are accessing.
        url: domain + "ajax.php",
        // The type of request.
        type: "post",
        data: "act=change_user_info&fullname=" + $('#fullname').val() + "&phone=" + $('#phone').val() + "&day=" + $('#day').val() + "&month=" + $('#month').val() + "&year=" + $('#year').val() + "&id=" + $('#id').val() + "&gender=" + $('input[name=gender]:radio:checked').val(),
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
            // Load the content in to the page.
            $("#error").html("<label>Page Not Found!!</label>");
            $("#error").css({display: "block"});
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData != "") {
                $("#error").html(strData);
                $("#error").css({display: "block"});
            } else {
//                                    window.location.href = <?php echo DOMAIN ?>;
            }
        }
    });
}
/**
 * 
 * @param {type} domain
 * @returns {undefined}
 * 
 */
function loginUser(domain) {
    $.ajax({
        // The link we are accessing.
        url: domain + "ajax.php",
        // The type of request.
        type: "post",
        data: "act=login&email=" + $('#login_email').val() + "&pass=" + $('#login_pass').val(),
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
            // Load the content in to the page.
            $("#err_login").html("<label>Page Not Found!!</label>");
            $("#err_login").css({display: "block"});
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData == 1) {
                window.location.href = domain;
            } else {
                $("#err_login").html(strData);
                $("#err_login").css({display: "block"});
            }
        }
    });
}

function loginUserForm(domain) {
    $.ajax({
        // The link we are accessing.
        url: domain + "ajax.php",
        // The type of request.
        type: "post",
        data: "act=login_user&email=" + $('#_email').val() + "&pass=" + $('#_password').val(),
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
            // Load the content in to the page.
            $("#message").html("<label>Page Not Found!!</label>");
            $("#message").css({display: "block"});
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData == 1) {
                window.location.href = domain;
            } else {
                $("#message").html(strData);
                $("#message").css({display: "block"});
            }
        }
    });
}

function addodd($values) {
    $.ajax({
        // The link we are accessing.
        url: "/ajax.php",
        // The type of request.
        type: "get",
        data: "act=addodd&values=" + $values,
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData == 0) {
                alert('Kèo của trận này đã được đặt.');
            } else if (strData == -1) {
                alert('Hết thời gian dự đoán.');
            } else {
                $("#result_bets").html(strData);
                $("#BeeperBox").show();
                timerId = setTimeout(function () {
                    $("#BeeperBox").hide();
                }, 2000);
            }
        }
    });
}

function update_datcuoc($type, $values, $key, $index_key) {
    $.ajax({
        // The link we are accessing.
        url: "/ajax.php",
        // The type of request.
        type: "get",
        data: "act=update_datcuoc&type=" + $type + "&values=" + $values + "&key=" + $key + "&money=" + $('#number_money_' + $type + "_" + $key).val() + "&index_key=" + $index_key,
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData != "") {
                $("#message").html("<label>Thay đổi tỷ lệ dự đoán thành công.</label>");
                $('#message').css({display: "block"});
                $('#total_money_' + $type + "_" + $key).val(strData);
            }
        }
    });
}

function delete_datcuoc($type, $key) {
    $.ajax({
        // The link we are accessing.
        url: "/ajax.php",
        // The type of request.
        type: "get",
        data: "act=delete_datcuoc&type=" + $type + "&key=" + $key,
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
        },
        success: function(strData) {
            // Load the content in to the page.
            $("#loaddata").html(strData);
        }
    });
}

function addoddsx($values) {
    $.ajax({
        // The link we are accessing.
        url: "/ajax.php",
        // The type of request.
        type: "get",
        data: "act=addoddsx&values=" + $values + "&location=" + $('#location').val() + "&type=" + $('#type').val(),
        // The type of data that is getting returned.
        dataType: "html",
        error: function() {
        },
        success: function(strData) {
            // Load the content in to the page.
            if (strData == 0) {
                alert('Số này đã được chọn');
            } else {
                $("#result_bets").html(strData);
            }
        }
    });
}